/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.store;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.model.SelectItem;
import oracle.jdbc.OracleTypes;
import queenb.net.datacontrol.DataStatement;
import queenb.net.datacontrol.Param;
import queenb.net.entitybean.N750;
import queenb.web.util.PackageContants;

/**
 *
 * @author VANANH
 */
public class N750Store extends N750 {
    // Tung: Lay danh sach quoc gia

    public List<N750> getListN750(int pn750) throws SQLException, InstantiationException, IllegalAccessException {
        DataStatement dataStatement = new DataStatement(PackageContants.LIST_N750, OracleTypes.CURSOR, new Param[]{
                    new Param(OracleTypes.INTEGER, pn750)
                });

        System.out.println("Country------------------------------------->" + pn750);
        return super.find(dataStatement, N750.class);
    }

    public List<SelectItem> getN750Select() throws SQLException, InstantiationException, IllegalAccessException {
        List<N750> lstN750 = getListN750(0);
        List<SelectItem> selectItems = new ArrayList<SelectItem>();
        for (int i = 0; i < lstN750.size(); i++) {
            N750 n750 = lstN750.get(i);
            selectItems.add(new SelectItem(n750.getPn750(), n750.getNv754()));
        }
        return selectItems;
    }

    public List<N750> findAllN750ForCombo(int pnFH000, int pnFH200, int pnFK100, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_N750, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.INTEGER, pnFK100),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, N750.class);
        } catch (SQLException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public List<N750> findAllN750ForComboDV(int pnFH000, int pnFH200, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_N750_DV, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnFH000),
                        new Param(OracleTypes.INTEGER, pnFH200),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, N750.class);
        } catch (SQLException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    //
    public List<N750> findAllN750ForAll(int pnPN750, String pvLOGIN) {
        try {
            DataStatement dataStatement = new DataStatement(PackageContants.COMBO_N750ALL, OracleTypes.CURSOR, new Param[]{
                        new Param(OracleTypes.INTEGER, pnPN750),
                        new Param(OracleTypes.CHAR, pvLOGIN)
                    });
            return super.find(dataStatement, N750.class);
        } catch (SQLException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (InstantiationException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        } catch (IllegalAccessException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public int IMPORTTABN750(String pvNV753, String pvNV754, String pvAV001, int pnAN006, String pvLOGIN) {
        try {
            DataStatement updateStatement = new DataStatement(PackageContants.IMPORTTABN750, OracleTypes.INTEGER, new Param[]{
                       
                        new Param(OracleTypes.CHAR, pvNV753),
                        new Param(OracleTypes.CHAR, pvNV754),                        
                        new Param(OracleTypes.CHAR, pvAV001),
                        new Param(OracleTypes.INTEGER, pnAN006),
                        new Param(OracleTypes.CHAR, pvLOGIN)});
            return super.update(updateStatement, N750.class);
        } catch (SQLException ex) {
            Logger.getLogger(N750Store.class.getName()).log(Level.SEVERE, null, ex);
            return -1;
        }
    }
}
